/**
 * 产品修改js
 */
var comValidform=null;
var returnStatus=false;
var questionUpdate={
	questionUE:null,
	key:null,
		
	startEvent:function(){
		 
		$("#recordTab ul").idTabs();
		questionUpdate.questionUE = UE.getEditor('question',{
			initialFrameHeight:340,
			initialFrameWidth:898
		});
		
		 
		questionUpdate.showInfo();
		
		comValidform=$(".com-addForm").Validform({
			datatype:{
				"m0-2" : /^[0-9]+(.[0-9]{1,2})?$/
			},
			tiptype:2,
			tipSweep:true,
			beforeSubmit:function(curform){
				var url = 'mgr/questionCtrl/update';
				var params = jsUtils.serializeJson($('.com-addForm'));
				var question = questionUpdate.questionUE.getContent();
				params.question=question;
				
				var cb = function(data){
					alert(data.msg);
					//成功返回
					if(data.resultCode==200){
						localStorage.removeItem(questionUpdate.key);
						//关闭窗口并刷新数据
						art.dialog.close();
						returnStatus=true;
					}
				};
				sendApiNoLoadSync(url, params, cb, 'POST');
				return false;
			}
		});
	},
	
	showInfo:function(){
		
		var id = art.dialog.data('updId');
		questionUpdate.key = id + "_question_Key";
		questionInfo = eval('(' + localStorage.getItem(questionUpdate.key) + ')');
		$("input[name='id']").val(questionInfo.id);
		$("input[name='name']").val(questionInfo.name);
		$("input[name='cts']").val(questionInfo.cts);
		$("input[name='creater']").val(questionInfo.creater);
		$("input[name='type']").val(questionInfo.type);
		if(questionInfo.questionText != null){
			questionUpdate.questionUE.ready(function() {
				questionUpdate.questionUE.setContent(questionInfo.questionText);
            });
		}
	},
	
	init:function(){
		questionUpdate.startEvent();
	}
}
$(document).ready(function() {
	questionUpdate.init();
});
function submitForm(){
	comValidform.submitForm();
	return returnStatus;
}